package com.dreamdance.queerball;

import android.graphics.Canvas;
import net.ds0101.framework.android.neox.util.NXEasingCurve;
import net.ds0101.framework.android.neox.action.NXAction;
import net.ds0101.framework.android.neox.action.NXZoom;
import net.ds0101.framework.android.neox.main.NXScene;
import net.ds0101.framework.android.neox.util.NXResourceConverter;
import net.ds0101.framework.android.neox.widget.NXBitmapSheet;
import net.ds0101.framework.android.neox.widget.NXSprite;

public class BallSprite extends NXSprite {
	private static NXBitmapSheet sTexture;
	private int mColorIndex;
	private NXAction mAction;
	
	public static BallSprite createBallSprite(NXScene scene) {
		if (null == sTexture) {
			sTexture = new NXBitmapSheet(NXResourceConverter.getBitmapFromResource(scene, R.drawable.eggs), 1, 8);
		}
		return new BallSprite();
	}

	private BallSprite() {
		super(sTexture);
		//mAction = NXRepeatForever.action(new NXPlay(500, new Point(0, mColorIndex), new Point(0, mColorIndex)));	
		mAction = new NXZoom(200, 1.0f, 1.2f, NXEasingCurve.Type.SineCurve);
	}

	public void changeColor(int index) {
		mColorIndex = index;
		setDisplayFrame(/*mColorIndex % 4 * 3*/0, /*mColorIndex / 4 * 4*/index);
	}
	
	@Override
	public void draw(Canvas canvas) {
		super.draw(canvas);
	}
	
	public void playAnimation(boolean loop) {
		/*runAction(NXRepeatForever.action(new NXPlay(500, new Point(mColorIndex % 4 * 3, mColorIndex / 4 * 4), 
				new Point(mColorIndex % 4 * 3 + 2, mColorIndex / 4 * 4))));	*/
		runAction(mAction);
	}
}
